package com.ruoyi.project.basedata.controller;

import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.page.TableDataInfo;
import com.ruoyi.project.basedata.entity.Card;
import com.ruoyi.project.basedata.service.CardService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * Description:SIM卡台账Controller
 *
 * @author jia
 * @create 2020-10-30 11:07
 */
@Controller
@RequestMapping("/base_card")
public class CardController extends BaseController {

    private String prefix = "basedata";

    @Autowired
    CardService cardService;

    @RequiresPermissions("basedata:card:view")
    @GetMapping()
    public String cardlist() {
        return prefix + "/card_list";
    }

    @RequiresPermissions("basedata:card:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(HttpServletRequest request) {
        Map<String, Object> parameter = getParameterMap(request);
        startPage();
        List<Card> list = cardService.selectCardList(parameter);
        return getDataTable(list);
    }

    @GetMapping("/cardDetail")
    public String cardDetail(String cardNo, ModelMap modelMap) {
        modelMap.addAttribute("card", cardService.getCard(cardNo));
        List<String> data1 = new ArrayList<String>();
        data1.add("1月");
        data1.add("2月");
        List data2 = new ArrayList<>();
        data2.add(333);
        data2.add(666);
        String []data3 ={"1月","2月"};
        modelMap.addAttribute("data1", data1);
        modelMap.addAttribute("data2", data2);
        return "basedata/cardDetails";
    }


}
